package com.lele.trans;

import com.lele.dao.JDBCUtilDao;

import java.sql.SQLException;

// 事务管理
public class TransactionManager {

    // 开启事务
    public static void beginTrans () throws SQLException {
        JDBCUtilDao.getConnection().setAutoCommit(false); // 关闭自动提交
    }

    // 提交事务
    public static void commit () throws SQLException {
        JDBCUtilDao.getConnection().commit();
        JDBCUtilDao.closeConn();
    }

    // 回滚事务
    public static void rollback () throws SQLException {
        JDBCUtilDao.getConnection().rollback();
        JDBCUtilDao.closeConn();
    }

}
